package com.example.lemonservice.module.user.controller;

import com.example.lemoncommon.entity.Result;
import com.example.lemonservice.entitiy.User;
import com.example.lemonservice.module.user.service.UserServiceImpl;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Api(tags = "API-user", value = "用户服务")
@RestController
public class UserController {

    private final UserServiceImpl userService;

    public UserController(UserServiceImpl userService) {
        this.userService = userService;
    }


    @GetMapping("/user/register")
    public Result<String> registerUser(@RequestParam("name") String name, @RequestParam("password") String password) {
        userService.registerUser(name, password);
        return Result.SUCCESS();
    }

    @GetMapping("/user/unregister")
    public Result<String> unregisterUser(@RequestParam("name") String name, @RequestParam("password") String password) {
        userService.unregisterUser(name, password);
        return Result.SUCCESS();
    }

    @GetMapping("/user/getAll")
    public Result<List<User>> getAllUser() {
        return Result.SUCCESS(userService.getAllUser());
    }
}
